home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
Softshoe
/
Lisa's Mac Parts
/
Clipboard
/
ScrapItem.cp
< prev
next >
Wrap
Text File
|
2000-06-23
|
982b
|
50 lines
// ScrapItem.cp
#ifndef ScrapItem_h
#include "ScrapItem.h"
#endif
#ifndef OSError_h
#include "OSError.h"
#endif
#ifndef MasterPointer_h
#include "MasterPointer.h"
#endif
#include <Scrap.h>
#include <Errors.h>
ScrapItem::ScrapItem( const ScrapType& theType )
: type( theType )
{
int32 result = GetScrap( 0, type.Value(), &offset );
if ( result < 0 && result != noTypeErr )
throw OSError( result );
exists = ( result != noTypeErr );
size = exists ? result : 0;
}
void ScrapItem::operator>>( MasterPointer& destination ) const
{
Assert( exists );
// Resize the handle myself, since I know the size
// and SetSize has good error reporting.
if ( destination.IsEmpty() )
destination.Allocate( size );
else
destination.SetSize( size );
int32 ignoredOffset;
int32 result = GetScrap( destination.Handle(), type.Value(), &ignoredOffset );
Assert( result != noTypeErr );
if ( result < 0 )
throw OSError( result );
Assert( result == size );
}